package com.jiuzhou.guanwang.jzcp.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.jiuzhou.guanwang.jzcp.R;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerAdapter;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerHolder;

import java.util.List;

class CodeAdapter extends BaseRecyclerAdapter<String> {

    public CodeAdapter(Context context, List<String> datas) {
        super(context, R.layout.item_code, datas);
    }

    @Override
    public void convert(BaseRecyclerHolder holder, String item, int position) {
        if (!TextUtils.isEmpty(item)) {
            if (item.contains("#")) {
                holder.setBackgroundRes(R.id.tv_code,R.drawable.ic_ball_blue1);
                holder.setText(R.id.tv_code,item.substring(0, item.indexOf("#")));
                return;
            }
            holder.setBackgroundRes(R.id.tv_code,R.drawable.ic_ball_red1);
            holder.setText(R.id.tv_code,item);
        }
    }
}
